package com.by.http;

/**
 * @version 1.0
 * @Author 彭彦彬
 * @Date 2025/4/8 19:45
 * @注释
 */
import java.io.OutputStream;

public class HttpResponse {
    private OutputStream outputStream;

    public HttpResponse(OutputStream outputStream) {
        this.outputStream = outputStream;
    }

    public void write(String content) throws Exception {
        String response = "HTTP/1.1 200 OK\r\n" +
                "Content-Type: text/html\r\n" +
                "Content-Length: " + content.getBytes().length + "\r\n" +
                "\r\n" +
                content;
        outputStream.write(response.getBytes());
        outputStream.flush();
    }
}
